feat(mango): extract mango client#1087
Conversation
|
@rogaldh is attempting to deploy a commit to the Solana Foundation Team on Vercel. A member of the Team first needs to authorize it. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile SummaryThis PR replaces the full Mango v3 per-instruction decoder (and its
Confidence Score: 5/5Safe to merge — the change is a well-scoped removal of a dead decoder with a clean detection-only replacement; no data paths are broken. All integration points (InstructionsSection, TokenHistoryCard, NAME_SOURCES chain, programs registry) are correctly wired. The discriminator table is pinned by dedicated tests that would catch future accidental shifts. The heavy @blockworks-foundation/mango-client is fully removed and the new workspace package has no production dependencies beyond already-present peer deps. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[TransactionInstruction] --> B{isMangoInstruction?}
B -- No --> C[Other decoders / Unknown]
B -- Yes --> D[getMangoInstructionLabel]
D --> E{discriminator readable?}
E -- 4+ bytes, known --> F["MANGO_INSTRUCTION_NAMES.get(discriminator)\ne.g. 'PlacePerpOrder'"]
E -- empty data --> G["'No data'"]
E -- unknown discriminator --> H["'Unknown'"]
F --> I["CommonInstructionDetailsCard\ntitle: 'Mango v3 (deprecated): PlacePerpOrder'\ndefaultRaw=true"]
G --> I
H --> I
I --> J[InstructionCard\nshows raw accounts + hex data]
K[Transaction History Row] --> L{isMangoInstruction?}
L -- Yes --> M[parseMangoInstructionTitle\nthrows on unknown → caught]
L -- No --> N[Other resolvers]
O[NAME_SOURCES chain\nuse-resolved-instruction-summaries] --> P[resolveMangoInstructionName\nprogramId + Uint8Array discriminator]
P --> Q[string name or undefined]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[TransactionInstruction] --> B{isMangoInstruction?}
B -- No --> C[Other decoders / Unknown]
B -- Yes --> D[getMangoInstructionLabel]
D --> E{discriminator readable?}
E -- 4+ bytes, known --> F["MANGO_INSTRUCTION_NAMES.get(discriminator)\ne.g. 'PlacePerpOrder'"]
E -- empty data --> G["'No data'"]
E -- unknown discriminator --> H["'Unknown'"]
F --> I["CommonInstructionDetailsCard\ntitle: 'Mango v3 (deprecated): PlacePerpOrder'\ndefaultRaw=true"]
G --> I
H --> I
I --> J[InstructionCard\nshows raw accounts + hex data]
K[Transaction History Row] --> L{isMangoInstruction?}
L -- Yes --> M[parseMangoInstructionTitle\nthrows on unknown → caught]
L -- No --> N[Other resolvers]
O[NAME_SOURCES chain\nuse-resolved-instruction-summaries] --> P[resolveMangoInstructionName\nprogramId + Uint8Array discriminator]
P --> Q[string name or undefined]
Reviews (13): Last reviewed commit: "chore: dedupe pnpm catalogs and drop sta..." | Re-trigger Greptile |
|
@greptile-apps issues were addressed |
316cc76 to
b649d04
Compare
Description
Removes the Mango v3 instruction decoder and keeps only lightweight detection, so the explorer recognises the (dead) Mango v3 protocol and marks it deprecated without bundling
@blockworks-foundation/mango-client/@project-serum/serum. Detection lives in a dedicated@explorer/decoder-mangoworkspace package.packages/decoder-mangoexposes detection only —isMangoInstruction,parseMangoInstructionTitle,resolveMangoInstructionName,getMangoInstructionLabel,MANGO_PROGRAM_IDS,MANGO_V3_PROGRAM_LABEL(plus a/detectionsubpath). The per-instruction decoders, market lookups, hooks, and their fixtures/tests are gone. With the decoder deleted, the heavy@blockworks-foundation/mango-clientis no longer used anywhere and drops out of the lockfile entirely. (@project-serum/serumstays — it's used by the separate Serum decoder, not Mango.)instruction-program-mangofeature slice are removed. Mango v3 instructions now render through a genericCommonInstructionDetailsCard(resolves the program label from the registry, shows raw data), titled e.g.Mango v3 (deprecated): PlacePerpOrder— orNo data/Unknownwhen the payload can't be named.app/utils/programs.tsregisters the three Mango v3 program IDs (devnet / testnet / mainnet) with the deprecated label sourced from the package'sMANGO_V3_PROGRAM_LABEL— the package is the single source of truth for the addresses + label.NAME_SOURCESchain (resolveMangoInstructionName) — no payload decoding.Mango v4 is intentionally out of scope: it's a separate, active Anchor program that resolves its own name/instructions via its on-chain IDL (shown with the existing self-reported indicator), so it needs no bundled decoder or registry entry.
Type of change
Refactor + deprecation. Replaces the heavy Mango v3 decoder with detection-only recognition and a deprecation notice. Behaviour change: Mango v3 instructions render a generic deprecated card instead of per-instruction detail cards.
Screenshots
Mango v3 instructions render a single generic card —
Mango v3 (deprecated): <name>over the raw instruction data — instead of the previous per-instruction detail cards. No new screens; not a protocol integration.Testing
packages/decoder-mangounit tests cover detection across all instruction variants and edge cases (non-mango program, unknown discriminator, empty/short data) forisMangoInstruction,parseMangoInstructionTitle,resolveMangoInstructionName, andgetMangoInstructionLabel.CommonInstructionDetailsCard(named / no-data / unknown), covered by the Vitest story sweep.pnpm lint,pnpm test, and apptsc --noEmitpass locally; the packagedistwas rebuilt detection-only (nomango-client).Related Issues
HOO-452
Checklist
pnpm test,pnpm lint,pnpm typecheck)build:infoscript to update build informationAdditional Notes
master;pnpm-lock.yamlregenerated — the workspace now includespackages/decoder-mango, and@blockworks-foundation/mango-clientis gone entirely (@project-serum/serumremains, used by the Serum decoder).